library(dplyr)
library(magrittr)
library(tidyr)
library(ggplot2)

dat <- rio::import("data/Demo_book_country_3.dta")

p <- dat %>%
  filter(year == 2010) %>%
  ggplot(aes(x = dr_ig, y = v2x_polyarchy_imp_100)) +
  geom_point() + 
  geom_smooth(method = lm, se = FALSE) +
  xlim(20, 100) + 
  labs(y = "Democracy", x = "Index of Globalization") +
  theme(panel.grid.minor = element_blank(),
        panel.background = element_blank(),
        panel.grid.major = element_blank(),
        panel.border = element_blank(),
        axis.line = element_line(color = "black"),
        plot.margin = margin(1, 1, 1, 0.25, "cm"))

## ggsave(p, file = "figure_16_2.png",
##        width = 11, height = 8.5)

ggsave(p, file = "output/figure_16_2.tiff",
       width = 11, height = 8.5, dpi = 300)
